function getCookie(name){
    var re = new RegExp(name + "=([^;]+)");
    var value = re.exec(document.cookie);
    return (value != null) ? unescape(value[1]) : null;
}
function delCookie(name){
    document.cookie = name + '=;expires=Thu, 01 Jan 1970 00:00:01 GMT;';
}
function setCookie(c_name,value,exdays){
      var exdate=new Date();
      exdate.setDate(exdate.getDate() + exdays);
      var c_value=escape(value) + 
        ((exdays==null) ? "" : ("; expires="+exdate.toUTCString()));      
      document.cookie=c_name + "=" + c_value+";path=/";
}
function seoUrl(str){
    var unicodeNew = new Array();
    unicodeNew['a'] = new Array('á','à','ả','ã','ạ','ă','ắ','ặ','ằ','ẳ','ẵ','â','ấ','ầ','ẩ','ẫ','ậ');        
    unicodeNew['A'] = new Array('Á','À','Ả','Ã','Ạ','Ă','Ắ','Ặ','Ằ','Ẳ','Ẵ','Â','Ấ','Ầ','Ẩ','Ẫ','Ậ');
    unicodeNew['d'] = new Array('đ');
    unicodeNew['D'] = new Array('Đ');
    unicodeNew['e'] = new Array('é','è','ẻ','ẽ','ẹ','ê','ế','ề','ể','ễ','ệ');
    unicodeNew['E'] = new Array('É','È','Ẻ','Ẽ','Ẹ','Ê','Ế','Ề','Ể','Ễ','Ệ');
    unicodeNew['i'] = new Array('í','ì','ỉ','ĩ','ị');
    unicodeNew['I'] = new Array('Í','Ì','Ỉ','Ĩ','Ị');
    unicodeNew['o'] = new Array('ó','ò','ỏ','õ','ọ','ô','ố','ồ','ổ','ỗ','ộ','ơ','ớ','ờ','ở','ỡ','ợ');
    unicodeNew['O'] = new Array('Ó','Ò','Ỏ','Õ','Ọ','Ô','Ố','Ồ','Ổ','Ỗ','Ộ','Ơ','Ớ','Ờ','Ở','Ỡ','Ợ');
    unicodeNew['u'] = new Array('ú','ù','ủ','ũ','ụ','ư','ứ','ừ','ử','ữ','ự');
    unicodeNew['U'] = new Array('Ú','Ù','Ủ','Ũ','Ụ','Ư','Ứ','Ừ','Ử','Ữ','Ự');
    unicodeNew['y'] = new Array('ý','ỳ','ỷ','ỹ','ỵ');
    unicodeNew['Y'] = new Array('Ý','Ỳ','Ỷ','Ỹ','Ỵ');    
    unicodeNew['-'] = new Array(' ','-','_',',','---','--');
    //unicodeNew[''] = new Array('$','^','*','(',')','+','[','|','\','?');
    unicodeNew[''] = new Array('~','`','!','@','#','%','&','=',']','{','}',':',';','"',"'",'<','>','/');
    str = str.trim();
    for(var seoChar in unicodeNew){
        var uniArray = unicodeNew[seoChar];                    
        for(var i=0;i<uniArray.length;i++){            
            var re = new RegExp(uniArray[i],'g');
            str = str.replace(re,seoChar);            
        }                    
    }     
    str = str.replace(/[$^*(\\)+|?\[]/g,'');
    str = str.toLowerCase();                        
    return str;            
}        

$('#main-sidebar .accordion-heading a').click(function(){
    var id = $(this).attr('data');
    var item = $(this).parent().parent().find('ul');    
    if(item.html() === undefined){
        setCookie('menuActive',id,'2000000');
    }else{
        if(getCookie('menuCheck')==id){
            delCookie('menuCheck');
        }else{
            setCookie('menuCheck',id,'2000000');    
        }    
    }             
});
$('#main-sidebar .accordion-content a').click(function(){
    var id = $(this).parent().parent().attr('id');    
    setCookie('menuActive',id,'2000000');                
});

$('#footer-fix #footer-sidebar a').click(function(){    
    $('#main-sidebar .accordion-group ul').removeClass('in');
    $('#main-sidebar .accordion-group ul').css('height','0px');
    delCookie('menuCheck');
});


